#include <iostream>
#include <vector>

int main()
{
	unsigned size;

	std::cin >> size;

	typedef std::vector<unsigned> Array;
	typedef std::vector<Array> Table;

	Table coin_map(size, Array(size, 0u));
	Table max_coin(size, Array(size, 0u));

	unsigned last_step;
	for (unsigned i = 0; i != size; ++i)
	{
		for (unsigned j = 0; j != size; ++j)
		{
			std::cin >> coin_map[i][j];

			last_step = 0;

			if (i && max_coin[i - 1][j] > last_step)
				last_step = max_coin[i - 1][j];

			if (j && max_coin[i][j - 1] > last_step)
				last_step = max_coin[i][j - 1];

			max_coin[i][j] = coin_map[i][j] + last_step;
		}
	}

	std::cout << max_coin.back().back();

	return 0;
}